home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
Gold Medal Software 3
/
Gold Medal Software - Volume 3 (Gold Medal) (1994).iso
/
prog
/
palett.arj
/
DAC.ASM
< prev
next >
Wrap
Assembly Source File
|
1994-01-19
|
4KB
|
186 lines
;===========================================================================
; VGA DAC palette changing routines.
; Adapted from 'PC Intern' by Michael Tischer.
; Copyright (c) 1994 Jeffrey C. Moxon
;
; Notes:
; DAC routines work on VGA cards only. They can be replaced with
; calls to INT 0x10 functions 0x1012 and 0x1017, but even when called after
; vertical retrace, some monitors exhibit large amounts of flickering.
;===========================================================================
public _setdac ;VGA only
public _getdac ;VGA only
public _setborder
public _setvideomode
_CODE SEGMENT word public 'CODE'
ASSUME CS:_CODE;
;= Procedure to set block of DAC registers
;= Declare in C as: void far setdac(int start, int number, union dac *buff);
;= buff is a structure of DAC type:
;= union dac
;= {
;= struct
;= {
;= char red;
;= char green;
;= char blue;
;= } colors;
;= char RGB[3];
;= };
;=
_setdac proc far
push bp
mov bp,sp
mov dx,03DAH ;Wait for end of
Vscan: ;vertical rescan
in al,dx
test al,8
jne Vscan
Rscan:
in al,dx ;Go to start of rescan
test al,8
je Rscan
mov dx,03C6H ;Set Pel mask to 0xFF
mov al,0FFH
out dx,al
mov dx,03C8H ;Load Write address
mov al,byte ptr [bp+6] ;with starting number
out dx,al
xor cx,cx
mov dx,03C9H ;Load dx with register
SetNext:
les bx,dword ptr [bp+10] ;Load al with Red
mov al,byte ptr es:[bx]
out dx,al ;Set Red
mov al,byte ptr es:[bx+1] ;Set Green
out dx,al
mov al,byte ptr es:[bx+2] ;Set Blue
out dx,al
add word ptr [bp+10],3 ;Move to next DAC
inc cx
cmp cx,word ptr [bp+8] ;See if we changed
jl SetNext ;enough of them
pop bp
retf
_setdac endp
;= Procedure to read block of DAC registers
;= Declare in C as: void far getdac(int color, int num, union dac *buff);
;= buff is a structure of DAC type:
;= union dac
;= {
;= struct
;= {
;= char red;
;= char green;
;= char blue;
;= } colors;
;= char RGB[3];
;= };
;=
_getdac proc far
push bp
mov bp,sp
mov dx,03C7H ;Load write address
mov al,byte ptr [bp+6] ;with starting number
out dx,al
xor cx,cx
mov dx,03C9H ;Load dx with data register
ReadNext:
in al,dx ;Retrieve Red color
les bx,dword ptr [bp+10] ;Mov color to DAC struct
mov byte ptr es:[bx],al
nop ;Wait a bit
in al,dx ;Retrieve Green color
mov byte ptr es:[bx+1],al
nop ;Wait a bit
in al,dx ;Retrieve Blue color
mov byte ptr es:[bx+2],al
nop ;Wait a bit
add word ptr [bp+10],3 ;Move to next DAC
inc cx
cmp cx,word ptr [bp+8] ;Compare index to number
jl ReadNext
pop bp
retf
_getdac endp
;=
;= Procedure to set overscan color
;= Declare in C as: void far setborder(unsigned char color);
;=
_setborder proc far
push bp
mov bp, sp
mov bx, [bp + 6]
xchg bh, bl ;Color in bh
mov ax, 1001h
int 10h
mov sp, bp
pop bp
retf
_setborder endp
;=
;= Procedure to set video mode
;= Declare in C as: void far setvideomode(unsigned char mode);
;=
_setvideomode proc far
push bp
mov bp, sp
mov ax, [bp + 6]
mov ah, 0 ;Mode is in AL
int 10h
mov sp, bp
pop bp
retf
_setvideomode endp
_CODE ends
END